<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .swiper {
            width: 640px;
            height: 320px;
            overflow: hidden;
            position: relative;
        }

        .images-container {
            width: 1920px;
            height: 320px;
            display: flex;
            transition: transform 0.3s;
        }

        .images-container img {
            width: 640px;
            height: 320px;
        }

        /* .images-container:hover{
            transform: translate(-640px);  //写JavaScript程序之前先用css程序实现
        } */
        .number-list {
            position: absolute;
            bottom: 0;
        }
    </style>
</head>

<body>
    <div class="swiper">
        <div class="images-container">
            <img src="images/1.png" alt="">
            <img src="images/2.png" alt="">
            <img src="images/3.png" alt="">
        </div>
        <div class="number-list">
            <button>1</button>
            <button>2</button>
            <button>3</button>
        </div>
    </div>
    <script>
        let btnList = document.querySelectorAll(".number-list button");
        let container = document.querySelector(".images-container");
        for (let i in btnList) {
            btnList[i].onclick = function () {
                // 0 * 640 = 0;
                // 1 * 640 = 640;
                // 2 * 640 = 1280;
                /* .images-container:hover{
                   transform: translate(-640px);  //写JavaScript程序之前先用css程序实现
              } */
              //下边JavaScript的写法是从上面三行css演变来的
                container.style.transform = `translate(${-640 * i}px)`;
            }
        }
    </script>
</body>

</html>